package com.huyaanalysisplatform.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.huyaanalysisplatform.common.Result;
import com.huyaanalysisplatform.entity.TUser;
import com.huyaanalysisplatform.service.TUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.huyaanalysisplatform.controller.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Huadi Group 12
 * @since 2021-08-01
 */
@RestController
@RequestMapping
@CrossOrigin
public class TUserController extends BaseController {

    @Autowired
    TUserService tUserService;

    @PostMapping("/register")
    public Result register(@RequestBody TUser user){
        Result result = tUserService.register(user);
        return result;
    }

    @PostMapping("/loginEmail")
    public Result loginByEmail(@RequestBody TUser tUser){
        Result result = tUserService.loginByEmail(tUser.getEmail(), tUser.getPassword());
        return result;
    }

    @PostMapping("/login")
    public Result loginByPhone(@RequestBody TUser user){
        Result result = tUserService.loginByPhone(user.getPhone(), user.getPassword());
        return result;
    }

    @PostMapping("/user/edit")
    public Result edit(@RequestBody TUser user){
        Result result = tUserService.edit(user);
        return result;
    }
}
